package cn.com.homeyoda.aimate.aihealth.ui.activity;

import android.app.Application;
import android.util.Log;

import androidx.annotation.NonNull;

import cn.com.homeyoda.aimate.aihealth.base.BaseViewModel;
import cn.com.homeyoda.aimate.aihealth.bean.KePuBean;
import cn.com.homeyoda.aimate.aihealth.bean.MessageTitleBean;
import cn.com.homeyoda.aimate.aihealth.bean.MultipleItem;
import cn.com.homeyoda.aimate.aihealth.data.Repository;
import cn.com.homeyoda.aimate.aihealth.ui.my.ActivityBean;
import com.wzq.mvvmsmart.event.StateLiveData;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ActivityListViewModel extends BaseViewModel<Repository> {

    private List<ActivityBean> activityList = new ArrayList<>();
    public StateLiveData<List<ActivityBean>> activityData;
    public StateLiveData<List<MessageTitleBean>> titleData;


    public ActivityListViewModel(@NonNull Application application, Repository model) {
        super(application, model);
        titleData = new StateLiveData<>();
        titleData.setValue(new ArrayList<>());
        activityData = new StateLiveData<>();
        activityData.setValue(new ArrayList<>());
    }

    public void titleData() {
        List<MessageTitleBean> titleBeanList = new ArrayList<>();
        MessageTitleBean titleBean = new MessageTitleBean();
        titleBean.setTitle("全部");
        MessageTitleBean titleBean1 = new MessageTitleBean();
        titleBean1.setTitle("报名中");
        MessageTitleBean titleBean2 = new MessageTitleBean();
        titleBean2.setTitle("即将开始");
        MessageTitleBean titleBean3 = new MessageTitleBean();
        titleBean3.setTitle("我参与的");
        MessageTitleBean titleBean4 = new MessageTitleBean();
        titleBean4.setTitle("已结束");

        titleBeanList.add(titleBean);
        titleBeanList.add(titleBean1);
        titleBeanList.add(titleBean2);
        titleBeanList.add(titleBean3);
        titleBeanList.add(titleBean4);
        titleData.postSuccess();
        titleData.getValue().addAll(titleBeanList);
    }

    public void getActivityDataByType(int type) {
        List<ActivityBean> list = new ArrayList<>();
        if (type == 0) {
            list.addAll(activityList);
        } else {
            for (ActivityBean activity : activityList) {
                if (activity.getType() == type) {
                    list.add(activity);
                }
            }
        }
        activityData.getValue().clear();
        activityData.postSuccess();
        activityData.getValue().addAll(list);
        activityData.postValueAndSuccess(activityData.getValue());
    }

    public void getActivityData() {
        KePuBean kePuBean = new KePuBean();
        kePuBean.setContent("“二手烟”害人病，“二手酒”要人命");
        kePuBean.setName("张三");
        kePuBean.setNum("10.8");
        kePuBean.setTime("2025-02-28 18:18:18");
        KePuBean kePuBean1 = new KePuBean();
        kePuBean1.setContent("吃一颗抵十颗苹果？这才是维 生素含量最高的三种水果");
        kePuBean1.setName("李四");
        kePuBean1.setNum("13.5");
        kePuBean1.setTime("2025-02-27 18:18:18");
        KePuBean kePuBean2 = new KePuBean();
        kePuBean2.setContent("吃一颗抵十颗苹果？这才是维 生素含量最高的三种水果");
        kePuBean2.setName("王五");
        kePuBean2.setNum("1.8");
        kePuBean2.setTime("2025-02-18 18:18:18");
        KePuBean kePuBean3 = new KePuBean();
        kePuBean3.setContent("吃一颗抵十颗苹果？这才是维 生素含量最高的三种水果。吃一颗抵十颗苹果？这才是维 生素含量最高的三种水果");
        kePuBean3.setName("张三");
        kePuBean3.setNum("8.8");
        kePuBean3.setTime("2025-01-28 18:18:18");
        KePuBean kePuBean4 = new KePuBean();
        kePuBean4.setContent("吃一颗抵十颗苹果？这才是维 生素含量最高的三种水果");
        kePuBean4.setName("佚名");
        kePuBean4.setNum("13.5");
        kePuBean4.setTime("2025-02-27 18:18:18");
        KePuBean kePuBean5 = new KePuBean();
        kePuBean5.setContent("吃一颗抵十颗苹果？这才是维 生素含量最高的三种水果");
        kePuBean5.setName("一鸣");
        kePuBean5.setNum("1.8");
        kePuBean5.setTime("2025-02-18 18:18:18");

        activityList.add(new ActivityBean("", 1, "五一春游石老人露营", "活动的基本信息活动的基本信息", "2025-01-11 18:18:18", 666, 0, 88));
        activityList.add(new ActivityBean("", 2, "五一春游石老人露营", "活动的基本信息活动的基本信息", "2025-01-11 18:18:18", 888, 0, 77));
        activityList.add(new ActivityBean("", 3, "五一春游石老人露营", "活动的基本信息活动的基本信息", "2025-01-11 18:18:18", 777, 1, 99));
        activityList.add(new ActivityBean("", 4, "五一春游石老人露营", "活动的基本信息活动的基本信息", "2025-01-11 18:18:18", 999, 1, 66));
        activityList.add(new ActivityBean("", 3, "五一春游石老人露营", "活动的基本信息活动的基本信息", "2025-01-11 18:18:18", 333, 0, 22));
        activityList.add(new ActivityBean("", 2, "五一春游石老人露营", "活动的基本信息活动的基本信息", "2025-01-11 18:18:18", 555, 0, 11));
        activityList.add(new ActivityBean("", 1, "五一春游石老人露营", "活动的基本信息活动的基本信息", "2025-01-11 18:18:18", 222, 0, 55));
        activityList.add(new ActivityBean("", 4, "五一春游石老人露营", "活动的基本信息活动的基本信息", "2025-01-11 18:18:18", 111, 1, 33));
        activityData.postSuccess();
        activityData.getValue().addAll(activityList);
        activityData.postValueAndSuccess(activityData.getValue());
    }
}
